//
//  WEXBaseTableViewController.swift
//  microBlog
//
//  Created by apple on 16/4/16.
//  Copyright © 2016年 Hill. All rights reserved.
//

import UIKit

class WEXBaseTableViewController: UITableViewController,WEXVisitorViewDelegate {
    
    
    //设置登录属性
    var userLogon: Bool =  WEXUserAccountViewModel.sharedViewModel.isLogin
    
    override func loadView() {
        
//        print(userLogon)
        
        userLogon ? super.loadView() : setupView()
        
    }
    
    private func setupView() {
        
        view = visitor
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "registeButtonClick")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style:
            UIBarButtonItemStyle.Plain, target: self, action: "loginButtonClick")
    }
    
    // MARK: - 实现代理方法
    func registeButtonClick() {
        print("啊，注册了")
        
        
    }
    func loginButtonClick() {

        let Login = WEXOAuthViewController()
        
        self.presentViewController(UINavigationController(rootViewController: Login), animated: true, completion: nil)
        
    }
    
    // MARK: - 懒加载view
    lazy var visitor: WEXVisitorView = {
        let v = WEXVisitorView()
        v.delegate = self
        return v
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

   
}
